#! /bin/sh

name=groff
version=1.23.0
revision=1
tarball_url="https://ftp.gnu.org/gnu/groff/groff-${version}.tar.gz"
tarball_blake2b="9fc5a2302f034761a17f0639a04b82c536ba8a7db15b062dd736e0011fc5a27fddcaf035af128d09f06762825d9bb965e8f5561e4be7a9fea3fe86ca5f6cb2dd"
imagedeps="groff"
hostdeps="gcc pkg-config"
deps="core-libs"

prepare() {
    autotools_recursive_regen
}

configure() {
    autotools_configure \
        CFLAGS="$TARGET_CFLAGS -std=gnu17"
}

build() {
    make -j${parallelism} GROFFBIN=groff GROFF_BIN_PATH=/usr/bin
}

package() {
    DESTDIR="${dest_dir}" make install

    rm -f "${dest_dir}${prefix}/lib/charset.alias"

    # Move documentation to the correct location
    mv ${dest_dir}${prefix}/share/doc/groff-${version} ${dest_dir}${prefix}/share/doc/groff

    post_package_strip
}
